#include <csignal>
#include <cstring>
#include <iostream>
#include <unistd.h>
using namespace std;
struct sigaction sig1, sig2;
void sigcb(int sig) {
    cout << "捕获到了一个信号：" << sig << endl;
    exit(0);
}
int main() {
    memset(&sig1, 0, sizeof(sig1));
    memset(&sig2, 0, sizeof(sig2));
    sig1.sa_handler = sigcb;
    sig1.sa_flags = 0;
    sigemptyset(&sig1.sa_mask);
    sigaction(SIGINT, &sig1, &sig2);
    while(1) {
        cout << "Running..." << endl;
        sleep(1);
    }
    return 0;
}